package vincent.com.layouttest.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;

import java.util.Random;

import vincent.com.layouttest.util.LogUtil;

/**
 * Created by chenzhengwen on 2015/12/8.
 */
public class MyService extends Service {
    private String mString = "hello world!";
    private Random mRandomGenerator = new Random();
    private final IBinder mBinder = new MyBinder();

    public class MyBinder extends Binder {
        public MyService getService(){
            return MyService.this;
        }
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return START_STICKY;
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    public int getRandomNumber(){
        LogUtil.i(LogUtil.DEBUG_TAG, "inside service instance is " + MyService.this.toString());
        return mRandomGenerator.nextInt(100);
    }
}
